﻿namespace ChessToys
{
    using System;
    using System.Collections.Generic;

    /// <summary>
    /// <see cref="IMoveGenerator"/> for <see cref="Bishop"/>.
    /// </summary>
    public class BishopMoveGenerator : AbstractPieceMoveGenerator<Bishop>
    {
        /// <inheritdoc />
        protected override ISet<Move> GenerateForSpecificPiece(Board board, Position start, Bishop piece)
        {
            // prepare result
            ISet<Move> moves = new HashSet<Move>();
            // up left
            moves.UnionWith(Crawl(board, start, new Position(-1, -1), new Position(-1, -1)));
            // up right
            moves.UnionWith(Crawl(board, start, new Position(1, -1), new Position(board.Size, -1)));
            // down right
            moves.UnionWith(Crawl(board, start, new Position(1, 1), new Position(board.Size, board.Size)));
            // down left
            moves.UnionWith(Crawl(board, start, new Position(-1, 1), new Position(-1, board.Size)));
            // return result
            return moves;
        }
    }
}
